<!DOCTYPE html>
<html lang="en">
  <head>
    <title>
      <% if content_for?(:title) %>
        <%= yield(:title) %> | LibreDMM
      <% else %>
        LibreDMM
      <% end %>
    </title>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <%= csrf_meta_tags %>

    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
    <%= yield :js %>

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-114278390-1"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'UA-114278390-1');
    </script>
  </head>

  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
      <a class="navbar-brand" href="/">LibreDMM</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarContent">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item">
            <a class="nav-link" href="/movies">Movies</a>
          </li>
        </ul>
        <ul class="navbar-nav ml-auto">
          <% if signed_in? %>
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" id="userDropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <%= current_user.email %>
              </a>
              <div class="dropdown-menu" aria-labelledby="userDropdownMenu">
                <%= link_to (t '.sign_out'), sign_out_path, method: :delete, class: 'dropdown-item' %>
              </div>
            </li>
          <% else %>
            <li class="nav-item">
              <%= link_to (t '.sign_in'), sign_in_path, class: 'nav-link'%>
            </li>
          <% end %>
        </ul>
      </div>
    </nav>

    <main role="main" class="container">
      <div id="flash">
        <% flash.each do |key, value| -%>
          <div id="flash_<%= key %>" class="alert alert-info alert-dismissable fade show" role="alert">
            <%=h value %>
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
          </div>
        <% end %>
      </div>
      <%= yield %>
    </main>
  </body>
</html>
